﻿@model ArbabTravelsERP.Models.CandidateModel
@{
    ViewBag.Title = "Add Client";
    Layout = "~/Views/Shared/_Layout.cshtml";
}



@using (Html.BeginForm("Create", "Client", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { @id = "formControl", @class = "form-horizontal", enctype = "multipart/form-data" }))
{
    @Html.AntiForgeryToken()

            <!-- page content -->
    <div class="right_col" role="main">
        <div class="">
            <div class="page-title">
                <div class="title_left">
                    <h3>Client</h3>
                </div>
            </div>
            <div class="clearfix"></div>
            <div class="row">
                <div class="col-md-12 col-sm-12 col-xs-12">
                    <div class="x_panel">
                        <div class="x_title">
                            <h2>Client</h2>
                            <div class="clearfix"></div>
                        </div>


                        <div class="x_content">
                            @if (@TempData["Success"] != null)
                            {
                                <div class="alert alert-success alert-dismissable">
                                    <button type="button" class="close" data-dismiss="alert"
                                            aria-hidden="true">
                                        &times;
                                    </button>
                                    @TempData["Success"]
                                </div>
                            }

                            @if (@TempData["Error"] != null)
                            {
                                <div class="alert alert-dismissable">
                                    <button type="button" class="close" data-dismiss="alert"
                                            aria-hidden="true">
                                        &times;
                                    </button>
                                    @ViewData["Error"]
                                </div>
                            }


                            <!-- Tabs -->
                            <br />

                            <!-- Smart Wizard -->
                            <div id="wizard" class="form_wizard wizard_horizontal">
                                <ul class="wizard_steps">
                                    <li>
                                        <a href="#step-1">
                                            <span class="step_no">1</span>
                                            <span class="step_descr">
                                                Step 1<br />
                                                <small>Personal Details</small>
                                            </span>
                                        </a>
                                    </li>

                                    <li>
                                        <a href="#step-2">
                                            <span class="step_no">2</span>
                                            <span class="step_descr">
                                                Step 2<br />
                                                <small>Contact Details</small>
                                            </span>
                                        </a>
                                    </li>
                                </ul>

                                <div id="step-1">
                                    <h2 class="StepTitle">Step 1 Personal Details</h2>
                                    <div class="col-md-12" style="margin-top: 10px">
                                        <div class="col-md-9">
                                            <form id="clientForm1" data-parsley-validate class="form-horizontal form-label-left">
                                                <div class="form-group">
                                                    <label class="control-label col-md-4 col-sm-4" for="registration">Registration No.<span class="required">*</span> </label>
                                                    <div class="col-md-8 col-sm-8">
                                                        @Html.TextBoxFor(model => model.REGISTRATION_NO, new { @id = "REGISTRATION_NO", @class = "form-control  col-md-7 col-xs-12", @autocomplete = "off", @maxlength = "20", @readonly = "readonly" })
                                                        @Html.ValidationMessageFor(model => model.REGISTRATION_NO, "", new { @class = "text-danger" })
                                                    </div>
                                                </div>

                                                <div class="form-group">
                                                    <label class="control-label col-md-4 col-sm-4">Company Name</label>
                                                    <div class="col-md-8 col-sm-8">
                                                        @Html.TextBoxFor(model => model.NAME, new { @id = "NAME", @class = "form-control col-md-10", @autocomplete = "off", style = "float: left;" })


                                                        <div id="autocomplete-container" style="position: relative; float: left; width: 400px;"></div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="control-label col-md-4 col-sm-4" for="contactPerson">
                                                        Contact Person<span class="required">*</span>
                                                    </label>
                                                    <div class="col-md-3 col-sm-3">

                                                        @Html.TextBoxFor(model => model.FIRST_NAME, new { @id = "FIRST_NAME", @class = "form-control col-md-7 col-xs-12", @placeholder = "First Name" })
                                                    </div>
                                                    <div class="col-md-2 col-sm-2">
                                                        @Html.TextBoxFor(model => model.MIDDLE_NAME, new { @id = "MIDDLE_NAME", @class = "form-control col-md-7 col-xs-12", @placeholder = "Middle Name" })
                                                    </div>
                                                    <div class="col-md-3 col-sm-3">
                                                        @Html.TextBoxFor(model => model.LAST_NAME, new { @id = "LAST_NAME", @class = "form-control col-md-7 col-xs-12", @placeholder = "Last Name" })
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label for="Designation" class="control-label col-md-4 col-sm-4">Designation </label>
                                                    <div class="col-md-8 col-sm-8">
                                                        @Html.DropDownListFor(model => model.CLIENT_DESIGNATION, ViewData["GetDesignation"] as SelectList, "Select Designation", new { @id = "CLIENT_DESIGNATION", @class = "form-control", @autocomplete = "off" })
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label for="Reference" class="control-label col-md-4 col-sm-4">Reference</label>
                                                    <div class="col-md-8 col-sm-8">
                                                        @Html.TextBoxFor(model => model.REFERENCE, new { @id = "REFERENCE", @class = "form-control col-md-7 col-xs-12", @placeholder = "Reference" })
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label for="CivilianNo" class="control-label col-md-4 col-sm-4">Civilian No</label>
                                                    <div class="col-md-8 col-sm-8">

                                                        @Html.TextBoxFor(model => model.CIVILIAN_NO, new { @id = "CIVILIAN_NO", @class = "form-control col-md-7 col-xs-12", @placeholder = "Civilian No" })
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label for="middle-name" class="control-label col-md-4 col-sm-4">Industry</label>
                                                    <div class="col-md-8 col-sm-8">
                                                        @Html.DropDownListFor(model => model.CLIENT_INDUSTRY_ID, ViewData["GetIndustry"] as SelectList, "Select Industry", new { @id = "CLIENT_INDUSTRY_ID", @class = "form-control", @autocomplete = "off" })
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label for="middle-name" class="control-label col-md-4 col-sm-4">Remark</label>
                                                    <div class="col-md-8 col-sm-8">
                                                        @Html.TextAreaFor(model => model.REMARK, new { @id = "REMARK", @class = "resizable_textarea form-control", @placeholder = "Remark", @autocomplete = "off", @style = "width: 100%; overflow: hidden; word-wrap: break-word; resize: horizontal; height: 87px;" })
                                                    </div>
                                                </div>
                                            </form>
                                        </div>
                                        <div class="col-md-3">

                                            <div class="fileinput fileinput-new" data-provides="fileinput">
                                                <div class="fileinput-preview thumbnail" data-trigger="fileinput" style="width: 200px; height: 150px;"></div>
                                                <div>
                                                    <span class="btn btn-default btn-file"><span class="fileinput-new">Select image</span><span class="fileinput-exists">Change</span><input type="file" name="..." id="SaveImage"></span>
                                                    <a href="#" class="btn btn-default fileinput-exists" data-dismiss="fileinput">Remove</a>
                                                    @Html.HiddenFor(model => model.USER_IMAGE_PATH)
                                                </div>

                                            </div>
                                        </div>
                                    </div>

                                </div>
                                <div id="step-2">
                                    <h2 class="StepTitle">Step 2 Contact Details</h2>
                                    <form id="clientForm2" class="form-horizontal form-label-left">
                                        <div class="groupAddress">
                                            <div class="form-group">
                                                <label class="control-label col-md-3 col-sm-3" for="contactPerson">
                                                    Address <span class="required">*</span>
                                                </label>
                                                <div class="col-md-2 col-sm-2">
                                                    @Html.DropDownListFor(model => model.ADDRESS_TYPE_ID, ViewData["GetAddressType"] as SelectList, "Select Address Type", new { @id = "ADDRESS_TYPE_ID", @class = "form-control", @autocomplete = "off" })

                                                </div>
                                                <div class="col-md-4 col-sm-4">
                                                    @Html.TextBoxFor(model => model.ADDRESS, new { @id = "ADDRESS", @class = " form-control", @placeholder = "Address", @autocomplete = "off" })
                                                </div>
                                                <div class="">
                                                    <button type="button" class="addAddress addButton" id="SaveAddress"><i class="fa fa-plus"></i></button>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <div class="col-xs-offset-3 col-md-3 col-sm-3">
                                                    @Html.DropDownListFor(model => model.COUNTRY_CODE, ViewData["GetCountryStateCity"] as SelectList, "Select Country", new { @id = "COUNTRY_CODE", @class = "form-control", @autocomplete = "off" })

                                                </div>
                                                <div class="col-md-3 col-sm-3">
                                                    @Html.DropDownListFor(model => model.STATE_CODE, ViewData["GetCountryStateCity"] as SelectList, "Select State", new { @id = "STATE_CODE", @class = "form-control", @autocomplete = "off" })

                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <div class="col-xs-offset-3 col-md-3 col-sm-3">
                                                    @Html.DropDownListFor(model => model.CITY_CODE, ViewData["GetCountryStateCity"] as SelectList, "Select City", new { @id = "CITY_CODE", @class = "form-control", @autocomplete = "off" })

                                                </div>
                                                <div class="col-md-3 col-sm-3">
                                                    @Html.TextBoxFor(model => model.VILLAGE, new { @id = "VILLAGE", @class = "form-control col-md-7 col-xs-12", @placeholder = "Village", @autocomplete = "off", @maxlength = "20" })

                                                </div>

                                            </div>

                                            <div class="form-group">
                                                <label for="middle-name" class="control-label col-md-3 col-sm-3">Pin Code</label>
                                                <div class="col-md-6 col-sm-6">
                                                    @Html.TextBoxFor(model => model.PIN_CODE, new { @id = "PIN_CODE", @class = " form-control", @placeholder = "Pin Code", @autocomplete = "off", @maxlength = "6", @onkeypress = "return isNumberKey(event)" })
                                                </div>
                                            </div>

                                            <table class="table  table-bordered table-responsive table-striped" id="tblchild"></table>
                                        </div>


                                        <div class="form-group">
                                            <label for="middle-name" class="control-label col-md-3 col-sm-3">Email Address</label>
                                            <div class="col-md-6 col-sm-6">
                                                @Html.TextBoxFor(model => model.EMAIL_ID, new { @id = "EMAIL_ID", @class = " form-control col-md-7 col-xs-12", @placeholder = "Email ID", @autocomplete = "off" })

                                                <span class="fa fa-envelope-o form-control-feedback right" aria-hidden="true"></span>
                                            </div>
                                            <div class="col-xs-1">
                                                <button type="button" class="addButton addEmailButton" id="SaveEmail"><i class="fa fa-plus"></i></button>
                                            </div>
                                        </div>
                                        <table class="table  table-bordered table-responsive table-striped form-group-sm" id="tblemail"></table>


                                        <div class="form-group">
                                            <label for="middle-name" class="control-label col-md-3 col-sm-3">Phone Number <span class="required">*</span></label>
                                            <div class="col-md-2 col-sm-2">
                                                @Html.DropDownListFor(model => model.PHONE_TYPE_ID, ViewData["GetAddressType"] as SelectList, new { @id = "PHONE_TYPE_ID", @class = "form-control", @autocomplete = "off" })

                                            </div>
                                            <div class="col-md-4 col-sm-4">
                                                @Html.TextBoxFor(model => model.PHONE_NO, new { @id = "PHONE_NO", @class = " form-control col-md-7 col-xs-12", @placeholder = "Phone No", @autocomplete = "off", @maxlength = "11", @onkeypress = "return isNumberKey(event)" })
                                                <span class="fa fa-phone form-control-feedback right" aria-hidden="true"></span>
                                            </div>
                                            <div class="col-xs-1">
                                                <button type="button" class="addButton addPhoneButton" id="SavePhone"><i class="fa fa-plus"></i></button>
                                            </div>
                                            <table class="table  table-bordered table-responsive table-striped form-group-sm" id="tblphone"></table>
                                        </div>

                                        <div class="form-group">
                                            <label for="middle-name" class="control-label col-md-3 col-sm-3">Website</label>
                                            <div class="col-md-6 col-sm-6">
                                                @Html.TextBoxFor(model => model.WEBSITE, new { @id = "WEBSITE", @class = " form-control col-md-7 col-xs-12", @placeholder = "Website", @autocomplete = "off" })

                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="middle-name" class="control-label col-md-3 col-sm-3">Skype</label>
                                            <div class="col-md-6 col-sm-6">
                                                @Html.TextBoxFor(model => model.SKYPE, new { @id = "SKYPE", @class = " form-control col-md-7 col-xs-12", @placeholder = "Skype", @autocomplete = "off" })
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="control-label col-md-3 col-sm-3">Remark</label>
                                            <div class="col-md-6 col-sm-6">
                                                @Html.TextAreaFor(model => model.CONTACT_REMARK, new { @id = "CONTACT_REMARK", @class = " form-control col-md-7 col-xs-12", @placeholder = "Remark", @autocomplete = "off" })
                                            </div>
                                        </div>

                                    </form>
                                </div>
                            </div>

                            <!-- End SmartWizard Content -->
                            @Html.ValidationSummary(false, "", new { @class = "text-danger" })



                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- form wizard -->
<script type="text/javascript" src="~/js/wizard/jquery.smartWizard.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $("#SaveImage").change(function (e) {
            var imagepath = $("#SaveImage").val();
            $("#USER_IMAGE_PATH").val(imagepath);
        });
    });
</script>
<script type="text/javascript">
    $(document).ready(function () {
        var regno = '@ViewData["RegNo"]';
        $("#REGISTRATION_NO").val(regno);

    });
</script>

@*Number event*@
<script type="text/javascript">
    function isNumberKey(evt) {

        var charCode = (evt.which) ? evt.which : event.keyCode

        if (charCode > 31 && (charCode < 48 || charCode > 57))

            return false;

        return true;

    }
</script>

 @*Smart Wizard*@
<script type="text/javascript">
    $(document).ready(function () {
        $('#wizard').smartWizard({
            //onLeaveStep: leaveAStepCallback,
            //onFinish: onFinishCallback
        });

        function leaveAStepCallback(obj, context) {
            //alert("Leaving step " + context.fromStep + " to go to step " + context.toStep);
            return validateTab(context.fromStep); // return false to stay on step and true to continue navigation
        }

        function onFinishCallback(objs, context) {
            //if(validateAllSteps()){

            $('#formControl').submit();
            //}
        }
    });
</script>
   
@*State Binding with Country Code*@
<script type="text/javascript">
    $(document).ready(function () {
        //Dropdownlist Selectedchange event
        $("#COUNTRY_CODE").change(function () {
            $("#STATE_CODE").empty();
            $.ajax({
                type: 'POST',
                url: '@Url.Action("GetStateByCountryCode")', // we are calling json method
                dataType: 'json',
                data: { Country_code: $("#COUNTRY_CODE").val() },
                success: function (states) {
                    $("#STATE_CODE").append('<option value="0">--Select State--</option>');
                    // states contains the JSON formatted list
                    // of states passed from the controller
                    $.each(states, function (i, state) {
                        $("#STATE_CODE").append('<option value="' + state.Value + '">' + state.Text + '</option>');
                    }); // here we are adding option for States
                },
                error: function (ex) {
                    $("#STATE_CODE").append('<option value="0">--Select State--</option>');
                }
            });
            return false;
        })
    });
</script>

@*City Binding with State Code*@
<script type="text/javascript">
    $(document).ready(function () {
        //Dropdownlist Selectedchange event
        $("#STATE_CODE").change(function () {
            $("#CITY_CODE").empty();
            $.ajax({
                type: 'POST',
                url: '@Url.Action("GetCityByStateCode")', // we are calling json method
                dataType: 'json',
                data: { State_code: $("#STATE_CODE").val() },
                success: function (states) {
                    $("#CITY_CODE").append('<option value="0">--Select City--</option>');
                    // states contains the JSON formatted list
                    // of states passed from the controller
                    $.each(states, function (i, state) {
                        $("#CITY_CODE").append('<option value="' + state.Value + '">' + state.Text + '</option>');
                    }); // here we are adding option for States
                },
                error: function (ex) {
                    $("#CITY_CODE").append('<option value="0">--Select City--</option>');
                }
            });
            return false;
        })
    });
</script>
    

@*Save Address*@
<script type="text/javascript">
    $(document).ready(function () {

        $("#SaveAddress").click(function (e) {
            var ADDRESS_TYPE_ID = $("#ADDRESS_TYPE_ID").val();
            var ADDRESS = $("#ADDRESS").val();
            var COUNTRY_CODE = $("#COUNTRY_CODE").val();
            var STATE_CODE = $("#STATE_CODE").val();
            var CITY_CODE = $("#CITY_CODE").val();
            var VILLAGE = $("#VILLAGE").val();
            var PIN_CODE = $("#PIN_CODE").val();

            if (ADDRESS_TYPE_ID == "") {
                alert("Please select Address Type");
                $("#ADDRESS_TYPE_ID").focus();
                return false;
            }
            if (ADDRESS == "") {
                alert("Please enter Address");
                $("#ADDRESS").focus();
                return false;
            }

            if (COUNTRY_CODE == "") {
                alert("Please select Country");
                $("#COUNTRY_CODE").focus();
                return false;
            }

            if (STATE_CODE == "") {
                alert("Please select State");
                $("#STATE_CODE").focus();
                return false;
            }
            if (CITY_CODE == "") {
                alert("Please select City");
                $("#CITY_CODE").focus();
                return false;
            }

            if (PIN_CODE == "") {
                alert("Please enter Pincode");
                $("#PIN_CODE").focus();
                return false;
            }

            $.ajax({
                type: 'POST',
                url: '@Url.Action("SaveAddressDetails")', // we are calling json method
                dataType: 'json',
                data: { address_type: $("#ADDRESS_TYPE_ID").val(), address: $("#ADDRESS").val(), citycode: $("#CITY_CODE").val(), pincode: $("#PIN_CODE").val(), village: $("#VILLAGE").val(), regno: $("#REGISTRATION_NO").val() },
                success: function (data) {
                    data = $.parseJSON(data);
                    var row = "";
                    row += "<tr><th>ID</th><th>Address</th><th>Country</th><th>StateCity</th><th>Village</th><th>Pincode</th><th></th></tr>"
                    $.each(data, function (index, item) {
                        row += "<tr><td>" + item.ID + "</td><td>" + item.Address + "</td><td>" + item.Country + "</td><td>" + item.StateCity + "</td><td>" + item.Village + "</td><td>" + item.Pin_Code + "</td> <td><a href='/Candidate/Delete/" + item.ID + "' class='lnkDelete'>Delete</a></td></tr>";
                    });
                    $("#tblchild").html(row);

                    $("#PIN_CODE").val('');
                    $("#VILLAGE").val('');
                    $("#ADDRESS").val('');
                    $("#ADDRESS_TYPE_ID").val('0');
                    $("#Country_Code").val('0');
                    $("#State_Code").val('0');
                    $("#City_Code").val('0');
                },
                error: function (ex) {

                }
            });
            return false;
        });
    });
</script>

@*Delete Addess*@
<script type="text/javascript">
    $(document).ready(function () {
        $("#tblchild").on("click", ".lnkDelete", function (e) {
            var href = $(this).context.href;
            var addressid = href.substr(href.indexOf("/") + 35)

            var answer = confirm("Are you sure you want to delete this record?");
            if (answer) {

                $.ajax({
                    type: 'POST',
                    url: '@Url.Action("DeleteAddressDetails")', // we are calling json method
                    dataType: 'json',
                    data: { addressid: addressid },
                    success: function (data) {
                        data = $.parseJSON(data);
                        var row = "";
                        row += "<tr><th>ID</th><th>Address</th><th>Country</th><th>StateCity</th><th>Village</th><th>Pincode</th><th></th></tr>"
                        $.each(data, function (index, item) {
                            row += "<tr><td>" + item.ID + "</td><td>" + item.Address + "</td><td>" + item.Country + "</td><td>" + item.StateCity + "</td><td>" + item.Village + "</td><td>" + item.Pin_Code + "</td> <td><a href='/Candidate/Delete/" + item.ID + "' class='lnkDelete'>Delete</a></td></tr>";
                        });
                        $("#tblchild").html(row);

                        $("#PIN_CODE").val('');
                        $("#VILLAGE").val('');
                        $("#ADDRESS").val('');
                        $("#ADDRESS_TYPE_ID").val('0');
                        $("#Country_Code").val('0');
                        $("#State_Code").val('0');
                        $("#City_Code").val('0');
                    },
                    error: function (ex) {
                    }
                });
                return false;
            }
            else {
                return false;
            }
        });
    });
</script>

@*Save Email*@
<script type="text/javascript">
    $(document).ready(function () {

        $("#SaveEmail").click(function (e) {
            var EMAIL_ID = $("#EMAIL_ID").val();

            if (EMAIL_ID == "") {
                alert("Please enter Email_ID");
                $("#EMAIL_ID").focus();
                return false;
            }

            $.ajax({
                type: 'POST',
                url: '@Url.Action("SaveEmailDetails")', // we are calling json method
                dataType: 'json',
                data: { EmailId: $("#EMAIL_ID").val() },
                success: function (data) {
                    data = $.parseJSON(data);
                    var row = "";
                    row += "<tr><th>ID</th><th>Email_ID</th><th></th></tr>"
                    $.each(data, function (index, item) {
                        row += "<tr><td>" + item.ID + "</td><td>" + item.EMAIL_ID + "</td><td><a href='/Candidate/Delete/" + item.ID + "' class='lnkDelete'>Delete</a></td></tr>";
                    });
                    $("#tblemail").html(row);

                    $("#EMAIL_ID").val('');
                },
                error: function (ex) {

                }
            });
            return false;
        });
    });
</script>

@*Delete Email*@
<script type="text/javascript">
    $(document).ready(function () {
        $("#tblemail").on("click", ".lnkDelete", function (e) {
            var href = $(this).context.href;
            var emailid = href.substr(href.indexOf("/") + 35)

            var answer = confirm("Are you sure you want to delete this record?");
            if (answer) {

                $.ajax({
                    type: 'POST',
                    url: '@Url.Action("DeleteEmailDetails")', // we are calling json method
                    dataType: 'json',
                    data: { emailid: emailid },
                    success: function (data) {
                        data = $.parseJSON(data);
                        var row = "";
                        row += "<tr><th>ID</th><th>Email_ID</th><th></th></tr>"
                        $.each(data, function (index, item) {
                            row += "<tr><td>" + item.ID + "</td><td>" + item.EMAIL_ID + "</td><td><a href='/Candidate/Delete/" + item.ID + "' class='lnkDelete'>Delete</a></td></tr>";
                        });
                        $("#tblemail").html(row);

                        $("#EMAIL_ID").val('');
                    },
                    error: function (ex) {
                    }
                });
                return false;
            }
            else {
                return false;
            }
        });
    });
</script>

@*Save Phone*@
<script type="text/javascript">
    $(document).ready(function () {

        $("#SavePhone").click(function (e) {
            var PHONE_TYPE_ID = $("#PHONE_TYPE_ID").val();
            var PHONE_NO = $("#PHONE_NO").val();

            if (PHONE_TYPE_ID == "") {
                alert("Please select Phone Type");
                $("#PHONE_TYPE_ID").focus();
                return false;
            }

            if (PHONE_NO == "") {
                alert("Please enter Phone No");
                $("#PHONE_NO").focus();
                return false;
            }

            $.ajax({
                type: 'POST',
                url: '@Url.Action("SavePhoneDetails")', // we are calling json method
                dataType: 'json',
                data: { PHONE_NO: PHONE_NO, PHONE_TYPE_ID: PHONE_TYPE_ID },
                success: function (data) {
                    data = $.parseJSON(data);
                    var row = "";
                    row += "<tr><th>ID</th><th>PhoneNo</th><th></th></tr>"
                    $.each(data, function (index, item) {
                        row += "<tr><td>" + item.ID + "</td><td>" + item.PHONE_NO + "</td><td><a href='/Candidate/Delete/" + item.ID + "' class='lnkDelete'>Delete</a></td></tr>";
                    });
                    $("#tblphone").html(row);

                    $("#PHONE_NO").val('');
                },
                error: function (ex) {

                }
            });
            return false;
        });
    });
</script>

@*Delete Phone*@
<script type="text/javascript">
    $(document).ready(function () {
        $("#tblphone").on("click", ".lnkDelete", function (e) {
            var href = $(this).context.href;
            var phoneid = href.substr(href.indexOf("/") + 35)

            var answer = confirm("Are you sure you want to delete this record?");
            if (answer) {

                $.ajax({
                    type: 'POST',
                    url: '@Url.Action("DeletePhoneDetails")', // we are calling json method
                    dataType: 'json',
                    data: { phoneid: phoneid },
                    success: function (data) {
                        data = $.parseJSON(data);
                        var row = "";
                        row += "<tr><th>ID</th><th>PhoneNo</th><th></th></tr>"
                        $.each(data, function (index, item) {
                            row += "<tr><td>" + item.ID + "</td><td>" + item.PHONE_NO + "</td><td><a href='/Candidate/Delete/" + item.ID + "' class='lnkDelete'>Delete</a></td></tr>";
                        });
                        $("#tblphone").html(row);

                        $("#PHONE_NO").val('');
                    },
                    error: function (ex) {
                    }
                });
                return false;
            }
            else {
                return false;
            }
        });
    });
</script>
    
                
    
}
